home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / role / AMScen_0_9.lha / AMScen / proving6.m < prev    next >
Text File  |  1995-01-21  |  24KB  |  932 lines

  1. /*
  2.  * Amiga MUD
  3.  *
  4.  * Copyright (c) 1995 by Chris Gray
  5.  */
  6.  
  7. /*
  8.  * proving6.m - the 3D maze area
  9.  */
  10.  
  11. private tp_proving6 CreateTable().
  12. use tp_proving6
  13.  
  14. define tp_proving6 p_pHasShovel CreateBoolProp().
  15. define tp_proving6 p_pMazeX CreateIntProp().
  16. define tp_proving6 p_pMazeY CreateIntProp().
  17. define tp_proving6 p_pMazeZ CreateIntProp().
  18. define tp_proving6 MAZE_MAX_X 15.
  19. define tp_proving6 MAZE_MAX_Y 9.
  20. define tp_proving6 MAZE_MAX_Z 9.
  21. define tp_proving6 MAZE_ENTER_X 8.
  22. define tp_proving6 MAZE_ENTER_Y 9.
  23. define tp_proving6 MAZE_ENTER_Z 5.
  24. define tp_proving6 MAZE_GOAL_X    11.
  25. define tp_proving6 MAZE_GOAL_Y    3.
  26. define tp_proving6 MAZE_GOAL_Z    5.
  27. define tp_proving6 p_rLayerList CreateThingListProp().
  28. define tp_proving6 p_rLayer CreateIntListProp().
  29. define tp_proving6 MAZE_OPEN    0b00.
  30. define tp_proving6 MAZE_NORMAL    0b01.
  31. define tp_proving6 MAZE_BLOCK    0b10.
  32. define tp_proving6 p_pSaveIdle CreateActionProp().
  33. define tp_proving6 p_oCurrentUser CreateThingProp().
  34.  
  35. define tp_proving6 r_shovelChamber CreateThing(r_provingCave).
  36. SetupRoomDP(r_shovelChamber, "in a small chamber", "").
  37. AutoGraphics(r_shovelChamber, AutoOpenRoom).
  38. Connect(r_doorsExit, r_shovelChamber, D_NORTH).
  39. r_shovelChamber@p_rNoGenerateMonsters := true.
  40.  
  41. define tp_proving6 o_trollShovel CreateThing(nil).
  42. SetupObject(o_trollShovel, r_shovelChamber,
  43.     "Shovel;Troll,King's.shovel;troll's,troll,king's,king",
  44.     "The shovel is the same size and shape as a normal garden shovel, but it "
  45.     "seems to be made of silver or some other shiny, whitish metal. There is "
  46.     "a faint greenish glow surrounding it.").
  47.  
  48. define tp_proving6 r_trollMaze CreateThing(nil).
  49. SetupRoomD(r_trollMaze, "", "").
  50. HConnect(r_shovelChamber, r_trollMaze, D_NORTH).
  51. Scenery(r_trollMaze, "chasm.rock.cavity").
  52. r_trollMaze@p_rHintString := "Explore carefully - there is a route!".
  53.  
  54. define tp_proving6 proc mazeDropCheck(thing what)status:
  55.     Print("You can't drop things here.\n");
  56.     fail
  57. corp;
  58. AddRoomDropChecker(r_trollMaze, mazeDropCheck, false).
  59.  
  60. define tp_proving6 o_drawBridge CreateThing(nil).
  61. FakeObject(o_drawBridge, r_trollMaze,
  62.     "bridge;wooden,draw.drawbridge;wooden.draw-bridge;wooden", "").
  63. o_drawBridge@p_oState := 0.
  64. define tp_proving6 proc drawBridgeDesc()string:
  65.     thing me;
  66.  
  67.     me := Me();
  68.     if me@p_pMazeZ = MAZE_GOAL_Z and me@p_pMazeY = MAZE_GOAL_Y + 3 and
  69.     me@p_pMazeX = MAZE_GOAL_X
  70.     then
  71.     "The drawbridge is quite old, but still in good condition. "
  72.     "It is currently " +
  73.     if o_drawBridge@p_oState = 0 then
  74.         "drawn up on the far side of the chasm."
  75.     else
  76.         "lowered into position across the chasm."
  77.     fi
  78.     else
  79.     "There is no drawbridge here."
  80.     fi
  81. corp;
  82. o_drawBridge@p_oDescAction := drawBridgeDesc.
  83.  
  84. define tp_proving6 proc mazeIdle()void:
  85.     thing me;
  86.     action a;
  87.  
  88.     me := Me();
  89.     me -- p_pHasShovel;
  90.     ABPrint(r_shovelChamber, nil, nil, "Clunk!\n");
  91.     AddTail(r_shovelChamber@p_rContents, o_trollShovel);
  92.     o_drawBridge@p_oState := 0;
  93.     a := me@p_pSaveIdle;
  94.     ignore SetCharacterIdleAction(a);
  95.     me -- p_pSaveIdle;
  96.     SetLocation(r_shovelChamber);
  97.     o_trollShovel -- p_oCurrentUser;
  98.     call(a, void)();
  99. corp;
  100.  
  101. define tp_proving6 proc touchShovel()status:
  102.     thing me;
  103.  
  104.     me := Me();
  105.     Print("As you touch the shovel, you feel a sharp shock, as of electricity."
  106.     " The shock momentarily clouds your mind, but even so you look with "
  107.     "bewilderment as the shovel seems to melt into your hand. When you "
  108.     "recover your senses, the shovel is gone, and you feel a strong "
  109.     "desire to dig. There is a nagging feeling of something tugging at "
  110.     "your mind, from somewhere to the northeast.\n");
  111.     OPrint("As " + me@p_pName + " touches the shovel, it seems to cloud or "
  112.     "blur, and then it is gone.\n");
  113.     me@p_pHasShovel := true;
  114.     DelElement(r_shovelChamber@p_rContents, o_trollShovel);
  115.     me@p_pSaveIdle := SetCharacterIdleAction(mazeIdle);
  116.     o_trollShovel@p_oCurrentUser := me;
  117.     succeed
  118. corp;
  119. o_trollShovel@p_oTouchChecker := touchShovel.
  120. define tp_proving6 proc getShovel(thing shovel)status:
  121.     touchShovel()
  122. corp;
  123. o_trollShovel@p_oGetChecker := getShovel.
  124.  
  125. define tp_proving6 proc leaveShovel()status:
  126.     thing me;
  127.  
  128.     me := Me();
  129.     if me@p_pHasShovel then
  130.     me -- p_pHasShovel;
  131.     Print("As you leave this chamber, you experience a momentary feeling "
  132.         "of loss.\n");
  133.     ABPrint(r_shovelChamber, nil, nil, "Clunk!\n");
  134.     AddTail(r_shovelChamber@p_rContents, o_trollShovel);
  135.     ignore SetCharacterIdleAction(me@p_pSaveIdle);
  136.     me -- p_pSaveIdle;
  137.     o_trollShovel -- p_oCurrentUser;
  138.     o_drawBridge@p_oState := 0;
  139.     fi;
  140.     continue
  141. corp;
  142. AddSouthChecker(r_shovelChamber, leaveShovel, false).
  143.  
  144. HUniConnect(r_shovelChamber, r_shovelChamber, D_NORTHWEST).
  145. HUniConnect(r_shovelChamber, r_shovelChamber, D_WEST).
  146. HUniConnect(r_shovelChamber, r_shovelChamber, D_SOUTHWEST).
  147. HUniConnect(r_shovelChamber, r_shovelChamber, D_NORTHEAST).
  148. HUniConnect(r_shovelChamber, r_shovelChamber, D_EAST).
  149. HUniConnect(r_shovelChamber, r_shovelChamber, D_SOUTHEAST).
  150. define tp_proving6 proc shovelNoGo()status:
  151.     if Me()@p_pHasShovel then
  152.     Print("The stone is much too hard for you to walk through!\n");
  153.     else
  154.     Print("You can't go in that direction.\n");
  155.     fi;
  156.     fail
  157. corp;
  158. AddNorthWestChecker(r_shovelChamber, shovelNoGo, false).
  159. AddWestChecker(r_shovelChamber, shovelNoGo, false).
  160. AddSouthWestChecker(r_shovelChamber, shovelNoGo, false).
  161. AddNorthEastChecker(r_shovelChamber, shovelNoGo, false).
  162. AddEastChecker(r_shovelChamber, shovelNoGo, false).
  163. AddSouthEastChecker(r_shovelChamber, shovelNoGo, false).
  164.  
  165. HUniConnect(r_shovelChamber, r_shovelChamber, D_UP).
  166. define tp_proving6 proc shovelUp()status:
  167.     if Me()@p_pHasShovel then
  168.     Print("The ceiling is too high - you cannot go up that way.\n");
  169.     else
  170.     Print("You can't go in that direction.\n");
  171.     fi;
  172.     fail
  173. corp;
  174. AddUpChecker(r_shovelChamber, shovelUp, false).
  175. HUniConnect(r_shovelChamber, r_shovelChamber, D_DOWN).
  176. define tp_proving6 proc shovelDown()status:
  177.     if Me()@p_pHasShovel then
  178.     Print("The stone of the floor is quite hard - you cannot go down that "
  179.         "way.\n");
  180.     else
  181.     Print("You can't go in that direction.\n");
  182.     fi;
  183.     fail
  184. corp;
  185. AddDownChecker(r_shovelChamber, shovelDown, false).
  186.  
  187. define tp_proving6 proc doShovelDig()void:
  188.     if Me()@p_pHasShovel then
  189.     Print("The stone of the floor is quite hard - you cannot go down that "
  190.         "way.\n");
  191.     else
  192.     Print("Digging through solid rock is quite difficult.\n");
  193.     fi;
  194. corp;
  195. AddSpecialCommand(r_shovelChamber, "dig,excavate,shovel", doShovelDig).
  196.  
  197. define tp_proving6 o_bridgeSign CreateThing(nil).
  198. FakeObject(o_bridgeSign, r_trollMaze, "sign", "").
  199. define tp_proving6 proc bridgeSignDesc()string:
  200.     thing me;
  201.  
  202.     me := Me();
  203.     if me@p_pMazeZ = MAZE_GOAL_Z and me@p_pMazeY = MAZE_GOAL_Y + 3 and
  204.     me@p_pMazeX = MAZE_GOAL_X
  205.     then
  206.     "You see nothing special about the sign. It reads:\n\n"
  207.     "\tSPEAK THE BOTTOM WORD\n"
  208.     else
  209.     "There is no sign here."
  210.     fi
  211. corp;
  212. o_bridgeSign@p_oDescAction := bridgeSignDesc.
  213. define tp_proving6 proc bridgeSignRead()string:
  214.     thing me;
  215.  
  216.     me := Me();
  217.     if me@p_pMazeZ = MAZE_GOAL_Z and me@p_pMazeY = MAZE_GOAL_Y + 3 and
  218.     me@p_pMazeX = MAZE_GOAL_X
  219.     then
  220.     "The sign reads:\n\n\tSPEAK THE BOTTOM WORD\n"
  221.     else
  222.     "There is no sign here."
  223.     fi
  224. corp;
  225. o_bridgeSign@p_oReadAction := bridgeSignRead.
  226.  
  227. define tp_proving6 proc trollMazeListen(string s)status:
  228.     thing me;
  229.  
  230.     me := Me();
  231.     if me@p_pMazeZ = MAZE_GOAL_Z and me@p_pMazeY = MAZE_GOAL_Y + 3 and
  232.     me@p_pMazeX = MAZE_GOAL_X
  233.     then
  234.     SetTail(s);
  235.     while
  236.         s := GetWord();
  237.         s ~= ""
  238.     do
  239.         if s == "LURT" and o_drawBridge@p_oState = 0 then
  240.         o_drawBridge@p_oState := 1;
  241.         Print("With a rumble and a bang, the drawbridge lowers into "
  242.             "place across the chasm.\n");
  243.         GSetPen(nil, C_BROWN);
  244.         GAMove(nil, MAZE_GOAL_X * 10 + 1, MAZE_GOAL_Y * 10 + 19);
  245.         GRectangle(nil, 7, 11, true);
  246.         fi;
  247.     od;
  248.     fi;
  249.     continue
  250. corp;
  251. AddRoomSayChecker(r_trollMaze, trollMazeListen, false).
  252.  
  253. define tp_proving6 proc questHeartDesc()string:
  254.     "Find the heart of the trolls."
  255. corp;
  256. define tp_proving6 proc questHeartCheck()void:
  257. corp;
  258. define tp_proving6 proc questHeartHint()string:
  259.     "It lies deep in the rock."
  260. corp;
  261. QuestDirect("Heart", questHeartDesc, questHeartCheck, questHeartHint).
  262.  
  263. define tp_proving6 proc maze(int z, y, x)int:
  264.     if z < 0 or z > MAZE_MAX_Z or
  265.     y < 0 or y > MAZE_MAX_Y or
  266.     x < 0 or x > MAZE_MAX_X
  267.     then
  268.     MAZE_BLOCK
  269.     else
  270.     (r_trollMaze@p_rLayerList[z]@p_rLayer[y] >>
  271.         ((MAZE_MAX_X - x) * 2)) & 0b11
  272.     fi
  273. corp;
  274.  
  275. define tp_proving6 p_rSpaceCount CreateIntProp().
  276. define tp_proving6 p_rSpaceVector CreateIntListProp().
  277. r_trollMaze@p_rSpaceCount := 0.
  278. r_trollMaze@p_rSpaceVector := CreateIntArray(6).
  279. define tp_proving6 proc markSpace(int dir)void:
  280.     int count;
  281.  
  282.     count := r_trollMaze@p_rSpaceCount;
  283.     r_trollMaze@p_rSpaceVector[count] := dir;
  284.     r_trollMaze@p_rSpaceCount := count + 1;
  285. corp;
  286. define tp_proving6 proc dumpSpaces()bool:
  287.     list int spaces;
  288.     int count, i;
  289.  
  290.     count := r_trollMaze@p_rSpaceCount;
  291.     spaces := r_trollMaze@p_rSpaceVector;
  292.     if count ~= 0 then
  293.     if count = 1 then
  294.         Print("There is open space ");
  295.     else
  296.         Print("There are open spaces ");
  297.     fi;
  298.     for i from 0 upto count - 1 do
  299.         if i ~= 0 then
  300.         if i = count - 1 then
  301.             Print(" and ");
  302.         else
  303.             Print(", ");
  304.         fi;
  305.         fi;
  306.         Print(
  307.         case spaces[i]
  308.         incase D_NORTH:
  309.             "to the north"
  310.         incase D_SOUTH:
  311.             "to the south"
  312.         incase D_EAST:
  313.             "to the east"
  314.         incase D_WEST:
  315.             "to the west"
  316.         incase D_UP:
  317.             "above you"
  318.         incase D_DOWN:
  319.             "below you"
  320.         default:
  321.             "?"
  322.         esac);
  323.     od;
  324.     Print(".");
  325.     r_trollMaze@p_rSpaceCount := 0;
  326.     true
  327.     else
  328.     false
  329.     fi
  330. corp;
  331.  
  332. define tp_proving6 proc drawFloor(int x, y, z)void:
  333.     int kind;
  334.  
  335.     kind := maze(z - 1, y, x);
  336.     if kind = MAZE_NORMAL then
  337.     GSetPen(nil, C_GOLD);
  338.     elif kind = MAZE_BLOCK then
  339.     GSetPen(nil, C_LIGHT_GREY);
  340.     else
  341.     GSetPen(nil, C_DARK_GREY);
  342.     fi;
  343.     GAMove(nil, x * 10, y * 10);
  344.     GRectangle(nil, 9, 9, true);
  345. corp;
  346.  
  347. define tp_proving6 proc drawBlock(int x, y, kind)void:
  348.  
  349.     if kind = MAZE_NORMAL then
  350.     GSetPen(nil, C_ORANGE);
  351.     else
  352.     GSetPen(nil, C_MEDIUM_GREY);
  353.     fi;
  354.     GAMove(nil, x * 10, y * 10);
  355.     GRectangle(nil, 9, 9, true);
  356. corp;
  357.  
  358. define tp_proving6 proc showMaze()void:
  359.     thing me;
  360.     int x, y, z, dx, dy, dz, x0, y0, kind;
  361.     bool needNewLine;
  362.  
  363.     me := Me();
  364.     if me@p_oLight or FindFlagOnList(me@p_pCarrying, p_oLight) then
  365.     x := me@p_pMazeX;
  366.     y := me@p_pMazeY;
  367.     z := me@p_pMazeZ;
  368.     dx := x - MAZE_GOAL_X;
  369.     dy := y - MAZE_GOAL_Y;
  370.     dz := z - MAZE_GOAL_Z;
  371.     if dz = 0 and dy = 0 and dx = 0 then
  372.         Print("You are in the heart of the trolls.\n");
  373.     elif dz = 0 and dy = 2 and dx = 0 then
  374.         Print("You are on a drawbridge.\n");
  375.     elif maze(z, y, x) = MAZE_NORMAL then
  376.         Print("You are in solid rock.\n");
  377.     else
  378.         Print("You are in a cavity in the rock.\n");
  379.     fi;
  380.     if maze(z + 1, y, x) = MAZE_OPEN then
  381.         markSpace(D_UP);
  382.     fi;
  383.     if maze(z - 1, y, x) = MAZE_OPEN then
  384.         markSpace(D_DOWN);
  385.     fi;
  386.     if maze(z, y - 1, x) = MAZE_OPEN then
  387.         markSpace(D_NORTH);
  388.     fi;
  389.     if maze(z, y + 1, x) = MAZE_OPEN then
  390.         markSpace(D_SOUTH);
  391.     fi;
  392.     if maze(z, y, x - 1) = MAZE_OPEN then
  393.         markSpace(D_WEST);
  394.     fi;
  395.     if maze(z, y, x + 1) = MAZE_OPEN then
  396.         markSpace(D_EAST);
  397.     fi;
  398.     needNewLine := dumpSpaces();
  399.     if z = MAZE_GOAL_Z and y = MAZE_GOAL_Y + 3 and x = MAZE_GOAL_X then
  400.         if o_drawBridge@p_oState = 0 then
  401.         Print(" There is a drawbridge drawn up on the other side of "
  402.             "the chasm, and there is a small sign on this side.");
  403.         else
  404.         Print(" There is a drawbridge across the chasm, and there "
  405.             "is a small sign on this side.");
  406.         fi;
  407.     fi;
  408.     if needNewLine then
  409.         Print("\n");
  410.     fi;
  411.     if dx ~= 0 or dy ~= 0 or dz ~= 0 then
  412.         if dx > -2 and dx < 2 then
  413.         dx := 0;
  414.         fi;
  415.         if dy > -2 and dy < 2 then
  416.         dy := 0;
  417.         fi;
  418.         if dz > -2 and dz < 2 then
  419.         dz := 0;
  420.         fi;
  421.         if dx = 0 and dy = 0 and dz = 0 then
  422.         Print("Whatever has been leading you around is very close.\n");
  423.         else
  424.         Print("The tugging is coming from ");
  425.         if dz ~= 0 then
  426.             if dz < 0 then
  427.             Print("above");
  428.             elif dz > 0 then
  429.             Print("below");
  430.             fi;
  431.             if dx ~= 0 or dy ~= 0 then
  432.             Print(" and from ");
  433.             fi;
  434.         fi;
  435.         if dx ~= 0 or dy ~= 0 then
  436.             Print("the ");
  437.             if dx < 0 then
  438.             if dy < 0 then
  439.                 Print("southeast");
  440.             elif dy = 0 then
  441.                 Print("east");
  442.             else
  443.                 Print("northeast");
  444.             fi;
  445.             elif dx = 0 then
  446.             if dy < 0 then
  447.                 Print("south");
  448.             elif dy > 0 then
  449.                 Print("north");
  450.             fi;
  451.             else
  452.             if dy < 0 then
  453.                 Print("southwest");
  454.             elif dy = 0 then
  455.                 Print("west");
  456.             else
  457.                 Print("northwest");
  458.             fi;
  459.             fi;
  460.         fi;
  461.         Print(".\n");
  462.         fi;
  463.     fi;
  464.     if GOn(nil) then
  465.         GSetPen(nil, C_BLACK);
  466.         GAMove(nil, 0, 0);
  467.         GRectangle(nil, 159, 99, true);
  468.         kind := maze(z, y, x);
  469.         if kind = MAZE_OPEN then
  470.         drawFloor(x, y, z);
  471.         else
  472.         drawBlock(x, y, kind);
  473.         fi;
  474.         if y > 0 then
  475.         kind := maze(z, y - 1, x);
  476.         if kind = MAZE_OPEN then
  477.             drawFloor(x, y - 1, z);
  478.             if y > 1 then
  479.             kind := maze(z, y - 2, x);
  480.             if kind = MAZE_OPEN then
  481.                 drawFloor(x, y - 2, z);
  482.             else
  483.                 drawBlock(x, y - 2, kind);
  484.             fi;
  485.             fi;
  486.         else
  487.             drawBlock(x, y - 1, kind);
  488.         fi;
  489.         if x < MAZE_MAX_X then
  490.             kind := maze(z, y - 1, x + 1);
  491.             if kind = MAZE_OPEN then
  492.             drawFloor(x + 1, y - 1, z);
  493.             else
  494.             drawBlock(x + 1, y - 1, kind);
  495.             fi;
  496.         fi;
  497.         fi;
  498.         if x < MAZE_MAX_X then
  499.         kind := maze(z, y, x + 1);
  500.         if kind = MAZE_OPEN then
  501.             drawFloor(x + 1, y, z);
  502.             if x < MAZE_MAX_X - 1 then
  503.             kind := maze(z, y, x + 2);
  504.             if kind = MAZE_OPEN then
  505.                 drawFloor(x + 2, y, z);
  506.             else
  507.                 drawBlock(x + 2, y, kind);
  508.             fi;
  509.             fi;
  510.         else
  511.             drawBlock(x + 1, y, kind);
  512.         fi;
  513.         if y < MAZE_MAX_Y then
  514.             kind := maze(z, y + 1, x + 1);
  515.             if kind = MAZE_OPEN then
  516.             drawFloor(x + 1, y + 1, z);
  517.             else
  518.             drawBlock(x + 1, y + 1, kind);
  519.             fi;
  520.         fi;
  521.         fi;
  522.         if y < MAZE_MAX_Y then
  523.         kind := maze(z, y + 1, x);
  524.         if kind = MAZE_OPEN then
  525.             drawFloor(x, y + 1, z);
  526.             if y < MAZE_MAX_Y - 1 then
  527.             kind := maze(z, y + 2, x);
  528.             if kind = MAZE_OPEN then
  529.                 drawFloor(x, y + 2, z);
  530.             else
  531.                 drawBlock(x, y + 2, kind);
  532.             fi;
  533.             fi;
  534.         else
  535.             drawBlock(x, y + 1, kind);
  536.         fi;
  537.         if x > 0 then
  538.             kind := maze(z, y + 1, x - 1);
  539.             if kind = MAZE_OPEN then
  540.             drawFloor(x - 1, y + 1, z)
  541.             else
  542.             drawBlock(x - 1, y + 1, kind);
  543.             fi;
  544.         fi;
  545.         fi;
  546.         if x > 0 then
  547.         kind := maze(z, y, x - 1);
  548.         if kind = MAZE_OPEN then
  549.             drawFloor(x - 1, y, z);
  550.             if x > 1 then
  551.             kind := maze(z, y, x - 2);
  552.             if kind = MAZE_OPEN then
  553.                 drawFloor(x - 2, y, z);
  554.             else
  555.                 drawBlock(x - 2, y, kind);
  556.             fi;
  557.             fi;
  558.         else
  559.             drawBlock(x - 1, y, kind);
  560.         fi;
  561.         if y > 0 then
  562.             kind := maze(z, y - 1, x - 1);
  563.             if kind = MAZE_OPEN then
  564.             drawFloor(x - 1, y - 1, z);
  565.             else
  566.             drawBlock(x - 1, y - 1, kind);
  567.             fi;
  568.         fi;
  569.         fi;
  570.         if z = MAZE_GOAL_Z and
  571.         x >= MAZE_GOAL_X - 1 and x <= MAZE_GOAL_X + 1 and
  572.         y >= MAZE_GOAL_Y and y <= MAZE_GOAL_Y + 3
  573.         then
  574.         x0 := MAZE_GOAL_X * 10;
  575.         y0 := MAZE_GOAL_Y * 10;
  576.         GSetPen(nil, C_RED_ORANGE);
  577.         GAMove(nil, x0 + 11, y0 + 31);
  578.         GPixel(nil);
  579.         GSetPen(nil, C_BROWN);
  580.         GAMove(nil, x0 + 1, y0 + 19);
  581.         if o_drawBridge@p_oState = 0 then
  582.             GRectangle(nil, 7, 2, true);
  583.         else
  584.             GRectangle(nil, 7, 11, true);
  585.         fi;
  586.         fi;
  587.         PlaceCursor(x * 10 + 1, y * 10 + 1);
  588.     fi;
  589.     else
  590.     Print("It is dark.\n");
  591.     fi;
  592. corp;
  593.  
  594. define tp_proving6 proc mazeLookChecker()status:
  595.     showMaze();
  596.     succeed
  597. corp;
  598. AddRoomLookChecker(r_trollMaze, mazeLookChecker, false).
  599.  
  600. define tp_proving6 proc enterMaze()status:
  601.     thing me;
  602.  
  603.     me := Me();
  604.     if me@p_pHasShovel then
  605.     me@p_pMazeX := MAZE_ENTER_X;
  606.     me@p_pMazeY := MAZE_ENTER_Y;
  607.     me@p_pMazeZ := MAZE_ENTER_Z;
  608.     o_drawBridge@p_oState := 0;
  609.     Print("Amazingly enough, you are able to walk right into the wall. "
  610.         "The stone seems to be soft, and it parts before you and closes "
  611.         "behind you.\n");
  612.     SetLocation(r_trollMaze);
  613.     if LightAt(r_shovelChamber) then
  614.         if not me@p_pHidden then
  615.         OPrint(me@p_pName + " disappears.\n");
  616.         ForEachAgent(r_shovelChamber, UnShowIconOnce);
  617.         fi;
  618.     else
  619.         ForEachAgent(r_shovelChamber, UnShowRoomFromAgent);
  620.     fi;
  621.     SetLocation(r_trollMaze);
  622.     if GOn(nil) then
  623.         RemoveCursor();
  624.         GUndrawIcons(nil);
  625.         GResetIcons(nil);
  626.         DrawRoomName("Solid", "Rock");
  627.     else
  628.         Print("Warning! This puzzle area is MUCH easier if you have "
  629.         "a graphics display!\n\n");
  630.     fi;
  631.     succeed
  632.     else
  633.     Print("You can't go in that direction.\n");
  634.     fail
  635.     fi
  636. corp;
  637. AddNorthChecker(r_shovelChamber, enterMaze, false).
  638.  
  639. define tp_proving6 proc mazeMove(int xDelta, yDelta, zDelta)status:
  640.     thing me;
  641.     int x, y, z, oldKind, kind;
  642.  
  643.     me := Me();
  644.     x := me@p_pMazeX;
  645.     y := me@p_pMazeY;
  646.     z := me@p_pMazeZ;
  647.     oldKind := maze(z, y, x);
  648.     if oldKind = MAZE_OPEN and zDelta = 1 then
  649.     Print("The ceiling is too high - you cannot go up that way.\n");
  650.     else
  651.     x := x + xDelta;
  652.     y := y + yDelta;
  653.     z := z + zDelta;
  654.     kind := maze(z, y, x);
  655.     if kind = MAZE_BLOCK then
  656.         Print("That rock is too hard for you to dig into.\n");
  657.     else
  658.         if oldKind ~= MAZE_OPEN or kind ~= MAZE_OPEN then
  659.         Print("You dig ");
  660.         if zDelta = -1 then
  661.             Print("downwards ");
  662.         elif zDelta = 1 then
  663.             Print("upwards ");
  664.         fi;
  665.         if kind = MAZE_OPEN then
  666.             Print("into a cavity in the rock.\n");
  667.         else
  668.             Print("through the rock.\n");
  669.         fi;
  670.         fi;
  671.         if kind = MAZE_OPEN then
  672.         while maze(z - 1, y, x) = MAZE_OPEN do
  673.             Print("There is a cavity beneath you - you fall.\n");
  674.             z := z - 1;
  675.         od;
  676.         fi;
  677.         me@p_pMazeX := x;
  678.         me@p_pMazeY := y;
  679.         me@p_pMazeZ := z;
  680.         if GOn(nil) then
  681.         RemoveCursor();
  682.         fi;
  683.         showMaze();
  684.     fi;
  685.     fi;
  686.     fail
  687. corp;
  688.  
  689. define tp_proving6 proc mazeMoveNorth()status:
  690.     thing me;
  691.  
  692.     me := Me();
  693.     if me@p_pMazeZ = MAZE_GOAL_Z and me@p_pMazeY = MAZE_GOAL_Y + 3 and
  694.     me@p_pMazeX = MAZE_GOAL_X and o_drawBridge@p_oState = 1
  695.     then
  696.     if GOn(nil) then
  697.         RemoveCursor();
  698.     fi;
  699.     me@p_pMazeY := MAZE_GOAL_Y + 2;
  700.     showMaze();
  701.     fail
  702.     else
  703.     if me@p_pMazeZ = MAZE_GOAL_Z and me@p_pMazeY = MAZE_GOAL_Y + 1 and
  704.         me@p_pMazeX = MAZE_GOAL_X
  705.     then
  706.         Print("You enter the heart of the trolls - their most sacred "
  707.         "place. Congratulations on finding it!\n");
  708.         DoQuest(questHeartCheck);
  709.     fi;
  710.     mazeMove(0, -1, 0)
  711.     fi
  712. corp;
  713. define tp_proving6 proc mazeMoveEast()status:
  714.     mazeMove(1, 0, 0)
  715. corp;
  716. define tp_proving6 proc mazeMoveSouth()status:
  717.     thing me;
  718.  
  719.     me := Me();
  720.     if me@p_pMazeX = MAZE_ENTER_X and
  721.     me@p_pMazeY = MAZE_ENTER_Y and
  722.     me@p_pMazeZ = MAZE_ENTER_Z
  723.     then
  724.     continue
  725.     elif me@p_pMazeZ = MAZE_GOAL_Z and me@p_pMazeY = MAZE_GOAL_Y + 1 and
  726.     me@p_pMazeX = MAZE_GOAL_X
  727.     then
  728.     if GOn(nil) then
  729.         RemoveCursor();
  730.     fi;
  731.     me@p_pMazeY := MAZE_GOAL_Y + 2;
  732.     showMaze();
  733.     fail
  734.     else
  735.     mazeMove(0, 1, 0)
  736.     fi
  737. corp;
  738. define tp_proving6 proc mazeMoveWest()status:
  739.     mazeMove(-1, 0, 0)
  740. corp;
  741. define tp_proving6 proc mazeMoveUp()status:
  742.     mazeMove(0, 0, 1)
  743. corp;
  744. define tp_proving6 proc mazeMoveDown()status:
  745.     mazeMove(0, 0, -1)
  746. corp;
  747.  
  748. HUniConnect(r_trollMaze, r_trollMaze, D_NORTH).
  749. HUniConnect(r_trollMaze, r_trollMaze, D_EAST).
  750. HUniConnect(r_trollMaze, r_shovelChamber, D_SOUTH).
  751. HUniConnect(r_trollMaze, r_trollMaze, D_WEST).
  752. HUniConnect(r_trollMaze, r_trollMaze, D_DOWN).
  753. HUniConnect(r_trollMaze, r_trollMaze, D_UP).
  754. AddNorthChecker(r_trollMaze, mazeMoveNorth, false).
  755. AddEastChecker(r_trollMaze, mazeMoveEast, false).
  756. AddSouthChecker(r_trollMaze, mazeMoveSouth, false).
  757. AddWestChecker(r_trollMaze, mazeMoveWest, false).
  758. AddUpChecker(r_trollMaze, mazeMoveUp, false).
  759. AddDownChecker(r_trollMaze, mazeMoveDown, false).
  760.  
  761. define tp_proving6 proc shovelDig()void:
  762.     ignore mazeMove(0, 0, -1);
  763. corp;
  764. AddSpecialCommand(r_trollMaze, "dig,excavate,shovel", shovelDig).
  765.  
  766. r_trollMaze@p_rLayerList := CreateThingList().
  767.  
  768. define tp_proving6 proc makeRow(string r)int:
  769.     int row, i;
  770.     string ch;
  771.  
  772.     row := 0;
  773.     for i from 0 upto MAZE_MAX_X do
  774.     row := row << 2;
  775.     ch := SubString(r, i, 1);
  776.     if ch = "B" then
  777.         row := row | MAZE_BLOCK;
  778.     elif ch = "N" then
  779.         row := row | MAZE_NORMAL;
  780.     elif ch = "." then
  781.         row := row | MAZE_OPEN;
  782.     else
  783.         Print("Illegal character in maze row: '" + ch + "'.\n");
  784.     fi;
  785.     od;
  786.     row
  787. corp;
  788.  
  789. define tp_proving6 proc makeLayer(string y0,y1,y2,y3,y4,y5,y6,y7,y8,y9)void:
  790.     thing th;
  791.     list int li;
  792.  
  793.     li := CreateIntArray(10);
  794.     li[0] := makeRow(y0);
  795.     li[1] := makeRow(y1);
  796.     li[2] := makeRow(y2);
  797.     li[3] := makeRow(y3);
  798.     li[4] := makeRow(y4);
  799.     li[5] := makeRow(y5);
  800.     li[6] := makeRow(y6);
  801.     li[7] := makeRow(y7);
  802.     li[8] := makeRow(y8);
  803.     li[9] := makeRow(y9);
  804.     th := CreateThing(nil);
  805.     th@p_rLayer := li;
  806.     AddTail(r_trollMaze@p_rLayerList, th);
  807. corp;
  808.  
  809. /* must be given from the bottom up */
  810.  
  811. makeLayer(    /* 0 */
  812.     "NNNNNNNNNNNNNNNN",
  813.     "NNNNNNNNNNNNNNNN",
  814.     "BNNNBNBNBBNNBBBN",
  815.     "BNNNBNBNBNBNNBNN",
  816.     "BNNNBNBNBBNNNBNN",
  817.     "BNNNBNBNBNBNNBNN",
  818.     "BBBNNBBNBNBNNBNN",
  819.     "NNNNNNNNNNNNNNNN",
  820.     "NNNNNNNNNNNNNNNN",
  821.     "BBBNBBBNBBBNBBBN").
  822.  
  823. makeLayer(    /* 1 */
  824.     "BBBBBBBBBBBBBBBB",
  825.     "BBBBBBBBBBBBBBBB",
  826.     "BBBBBBBBBBBBBBBB",
  827.     "BBBBBNBBBNBBBBBB",
  828.     "BBBBBBBBBBBBBBBB",
  829.     "BBBBBBBBBBBBBBBB",
  830.     "BBBBBBBBBBBBBBBB",
  831.     "BBBBBBBBBBBBBBBB",
  832.     "BBBBBBBBBBNBBBBB",
  833.     "BBBBBBBBBBBBBBBB").
  834.  
  835. makeLayer(    /* 2 */
  836.     "BBBBNN..B..NN..N",
  837.     "...B....B...BBBN",
  838.     ".B.BBB..B...BBBN",
  839.     ".....NN.B...BBBN",
  840.     ".B.BBBBBBBBBBBBB",
  841.     "...BNNNBBBBBBBBB",
  842.     ".B.BNBNBBBBBBBBN",
  843.     "...BNBNBBB.....N",
  844.     ".B.BNBNB.B.BBBBB",
  845.     "...BNBN..BBBNNNB").
  846.  
  847. makeLayer(    /* 3 */
  848.     "BBBB.NN...NN....",
  849.     "BBBB........BBB.",
  850.     "BBBBBB......B...",
  851.     "BBBBBBN.B...B.BB",
  852.     "BBBBBBBBBBBBB.BB",
  853.     "BBBB.B.B.B....BN",
  854.     "BBBB.B.B.BBBBBBN",
  855.     "BBBB...B.B......",
  856.     "BBBB...B.B......",
  857.     "BBBB..NNNNNNNNBB").
  858.  
  859. makeLayer(    /* 4 */
  860.     ".NBB..NNNNN...BB",
  861.     "..NN........BBBB",
  862.     "BBBBB.....BBBBBB",
  863.     "BBB.NNN...BBBBBB",
  864.     "BBBBBBBBBBBBBBBN",
  865.     "N....BBB.B...BBN",
  866.     "BBBB.BBBBBBBBBB.",
  867.     "......BB.BBBBBB.",
  868.     ".NNNNNNBBB..BBBB",
  869.     "......NNN..NBBBB").
  870.  
  871. makeLayer(    /* 5 */
  872.     ".NNB............",
  873.     "...B............",
  874.     ".........BBBB.B.",
  875.     "NBBN....BBB.B.NN",
  876.     "NBBBBBBBBBB.BBNN",
  877.     "NBBB..B..B...BBB",
  878.     "BBBB..B......BBB",
  879.     "......BB.BBBBB.B",
  880.     "......NBBB.....B",
  881.     "......NNNN.NNNNN").
  882.  
  883. makeLayer(    /* 6 */
  884.     "..BB.......B.BBB",
  885.     "..BB.......B..BB",
  886.     "BBBB...B.NBBB.BB",
  887.     "BBBN...BBNBBB.BB",
  888.     "BBBBBBBBBNBBBBNB",
  889.     "BBBB..B.BBBBBBNB",
  890.     "BBBB..BBBBBBBBNB",
  891.     "BBBBBBBBBBBBBBBB",
  892.     "BBBB...BBB......",
  893.     "BBBB........BBBB").
  894.  
  895. makeLayer(    /* 7 */
  896.     "BBB..BBBBBBB....",
  897.     "BBB....BBBB...B.",
  898.     "BBNN...NNNN...B.",
  899.     "...N...NBBBB..B.",
  900.     "BBBBBBBBBNB..BN.",
  901.     "NNNN..B..NB.BBN.",
  902.     "N.....BBBBB.....",
  903.     "N.......B...BBB.",
  904.     "N...............",
  905.     "NNNN........BBBB").
  906.  
  907. makeLayer(    /* 8 */
  908.     "BB.....NNNNNN.BB",
  909.     "BBN....NBBBBB.B.",
  910.     ".......NNNNBB.B.",
  911.     "BBBBBB.NBBBBB.BB",
  912.     "BBBBBBBBBBBBBBB.",
  913.     "BBBB..BBBBBBBBB.",
  914.     "BBBB..BBBBBBBBB.",
  915.     "BBBB...BBBBBBBBB",
  916.     "BBBB...BBBB.BBBB",
  917.     "BBBB...BBBB.BBBB").
  918.  
  919. makeLayer(    /* 9 */
  920.     "B......NBBBB.B..",
  921.     "....BBBBBBBB....",
  922.     "........NBBB.B..",
  923.     "BBBBBB..B....B..",
  924.     "........BB.B.B..",
  925.     "NNNN..B.BB.B.B..",
  926.     "N..........B.B..",
  927.     "N.NN...BB.BB.B..",
  928.     "N..N....B.B..BB.",
  929.     "NNNN............").
  930.  
  931. unuse tp_proving6
  932.